<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>列表</title>
    <script src="/jquery/jquery-3.2.1.min.js"></script>
    <script src="/layui/layui.js"></script>
    <link rel="stylesheet" href="/layui/css/layui.css" />
    <link rel="stylesheet" href="/css/coupon/couponManage/couponList/coupon-list.css">
    <script src="/js/public/public.js"></script>
</head>
<body>
<div class="layui-row">
    <div class="list">
        <div class="list-left layui-col-md8">
            <div class="list-left-left"></div>
            <p class="list-left-right" id="title">后台人员解封日志</p>
        </div>
        <div class="list-right layui-col-md4">
            <div class="functionButton">
                <button class="list-right-left layui-btn" style="margin-top: 3px" onclick="refresh()">
                    <i class="layui-icon layui-icon-refresh"></i>&nbsp;刷新
                </button>
                <button class="list-right-right layui-btn" id="goBack" style="margin-top: 3px">
                    <i class="layui-icon layui-icon-left"></i>&nbsp;返回
                </button>
            </div>
        </div>

    </div>
    <div class="layui-col-md12">
        <div class="layui-row query">
            <div class="layui-card headerCenter">
                <div class="layui-card-header backColor">
                    <i class="layui-icon">&#xe615;</i>
                    筛选查询
                </div>
                <div class="layui-card-body">
                    <form class="layui-form">
                        <div class="layui-form-item ">
                            <label class="layui-form-label">封停账号：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="account" placeholder="请输入封停账号" class="layui-input">
                            </div>

                            <label class="layui-form-label">封停原因：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="reason" class="layui-input" placeholder="请输入封停原因"/>
                            </div>

                            <div class="layui-inline">
                                <label class="layui-form-label" style="margin-left: 30px;">停封天数：</label>
                                <div class="layui-input-inline">
                                    <select name="days" style="width: 190px; height: 38px;" id="days">
                                        <option value=""></option>
                                        <option value="2">7</option>
                                        <option value="3">30</option>
                                        <option value="4">180</option>
                                    </select>
                                </div>
                            </div>
                            <div class="queryButtonBox">
                                <button lay-submit lay-filter="search" type="submit" class="layui-btn">
                                    <i class="layui-icon layui-icon-search"></i> 搜索
                                </button>
                                <button type="reset" class="layui-btn layui-btn-warm" >
                                    <i class="layui-icon layui-icon-refresh"></i> 重置
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-col-md12">
        <!--数据列表-->
        <div class="record" style="padding: 0 10px 0 10px;height: 100%">
            <!--表-->
            <table id="demoTable" lay-filter="demoTable"></table>
        </div>
        <!--表头样式-->
        <div id="tableHeader" style="display: none;">
            <i class="layui-icon layui-icon-align-left"></i>后台人员解封日志
        </div>
        <!--表内操作-->
        <div id="button_caozuo" style="display:none" >
            <a alt="删除" title="删除" href="javascript:;" lay-event="deleteLogTable">删除</a>
        </div>
    </div>
</div>
<script>
    layui.use(['jquery','layer','table','form'],function(){
        var $=layui.jquery;
        var layer=layui.layer;
        var table=layui.table;

        refresh=function refresh(){
            location.reload();
        }

        getTable('','','');

        search=function search(){
            var account=$("input[name=account]").val();
            var reason=$("input[name=reason]").val();
            var days=$("#days option:selected").text();
            getTable(account,reason,days);
        }

        function getTable(account,reason,days){
            var param={
                'account':account,
                'reason':reason,
                'days':days,
                'type':2
            }
            $.ajax({
                url:"/login/getJsUnseal",
                type:"post",
                dataType:"json",
                data:param,
                success:function (data) {
                    demoTable(data.data);
                }
            })
        }

        function demoTable(data) {
            table.render({
                elem: '#demoTable',
                title: "解封日志列表",
                data: data,
                toolbar: '#tableHeader',
                limit: 10,
                page: {
                    layout: ['count', 'prev', 'page', 'next', 'limit', 'skip', 'refresh'],
                    limits: [10, 20, 30],
                    first: "首页",
                    last: "尾页",
                },
                cols:[[
                    {type:'checkbox'},
                    {title: '序号',align:'center', templet: function (data) {
                            return data.LAY_INDEX;
                        }},
                    {field:"account",title:"封停账号",align:'center'},
                    {field:"endDate",title:"解封时间",align:'center'},
                    {field:"reason",title:"封停原因",align:'center'},
                    {field:"days",title:"封停天数",align:'center',templet:function(data) {
                            if(data.days==0){
                                return "已解封";
                            }else{
                                return data.days+"天";
                            }
                        }},
                    {field:'',title:"操作",align:'center',toolbar:'#button_caozuo'}
                ]]
            })
        }

        table.on('tool(demoTable)',function (obj) {
            var event = obj.event;
            if(event == "deleteTable") {
                layer.confirm('确认要删除吗?', {icon: 3, title:'提示'}, function(index){
                    $.ajax({
                        url:"/login/deleteJsUnseal",
                        data:{'id':obj.data.id},
                        type:"post",
                        dataType:"json",
                        success:function (data) {
                            layer.msg("删除成功");
                            getTable('','','');
                        }
                    })
                    layer.close(index);
                })
            }
        })


    })

</script>
</body>
</html>